package com.elinshaw.service;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 *
 */
@javax.annotation.Generated(
        value = "by gRPC proto compiler (version 1.24.1)",
        comments = "Source: message.proto")
public final class MessageServiceGrpc {

    private MessageServiceGrpc() {
    }

    public static final String SERVICE_NAME = "com.elinshaw.proto.MessageService";

    // Static method descriptors that strictly reflect the proto.
    private static volatile io.grpc.MethodDescriptor<com.elinshaw.proto.Request,
            com.elinshaw.proto.Response> getControlTerminalMethod;

    @io.grpc.stub.annotations.RpcMethod(
            fullMethodName = SERVICE_NAME + '/' + "controlTerminal",
            requestType = com.elinshaw.proto.Request.class,
            responseType = com.elinshaw.proto.Response.class,
            methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
    public static io.grpc.MethodDescriptor<com.elinshaw.proto.Request,
            com.elinshaw.proto.Response> getControlTerminalMethod() {
        io.grpc.MethodDescriptor<com.elinshaw.proto.Request, com.elinshaw.proto.Response> getControlTerminalMethod;
        if ((getControlTerminalMethod = MessageServiceGrpc.getControlTerminalMethod) == null) {
            synchronized (MessageServiceGrpc.class) {
                if ((getControlTerminalMethod = MessageServiceGrpc.getControlTerminalMethod) == null) {
                    MessageServiceGrpc.getControlTerminalMethod = getControlTerminalMethod =
                            io.grpc.MethodDescriptor.<com.elinshaw.proto.Request, com.elinshaw.proto.Response>newBuilder()
                                    .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
                                    .setFullMethodName(generateFullMethodName(SERVICE_NAME, "controlTerminal"))
                                    .setSampledToLocalTracing(true)
                                    .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                                            com.elinshaw.proto.Request.getDefaultInstance()))
                                    .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                                            com.elinshaw.proto.Response.getDefaultInstance()))
                                    .setSchemaDescriptor(new MessageServiceMethodDescriptorSupplier("controlTerminal"))
                                    .build();
                }
            }
        }
        return getControlTerminalMethod;
    }

    /**
     * Creates a new async stub that supports all call types for the service
     */
    public static MessageServiceStub newStub(io.grpc.Channel channel) {
        return new MessageServiceStub(channel);
    }

    /**
     * Creates a new blocking-style stub that supports unary and streaming output calls on the service
     */
    public static MessageServiceBlockingStub newBlockingStub(
            io.grpc.Channel channel) {
        return new MessageServiceBlockingStub(channel);
    }

    /**
     * Creates a new ListenableFuture-style stub that supports unary calls on the service
     */
    public static MessageServiceFutureStub newFutureStub(
            io.grpc.Channel channel) {
        return new MessageServiceFutureStub(channel);
    }

    /**
     *
     */
    public static abstract class MessageServiceImplBase implements io.grpc.BindableService {

        /**
         *
         */
        public void controlTerminal(com.elinshaw.proto.Request request,
                                    io.grpc.stub.StreamObserver<com.elinshaw.proto.Response> responseObserver) {
            asyncUnimplementedUnaryCall(getControlTerminalMethod(), responseObserver);
        }

        @Override
        public final io.grpc.ServerServiceDefinition bindService() {
            return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
                    .addMethod(
                            getControlTerminalMethod(),
                            asyncUnaryCall(
                                    new MethodHandlers<
                                            com.elinshaw.proto.Request,
                                            com.elinshaw.proto.Response>(
                                            this, METHODID_CONTROL_TERMINAL)))
                    .build();
        }
    }

    /**
     *
     */
    public static final class MessageServiceStub extends io.grpc.stub.AbstractStub<MessageServiceStub> {
        private MessageServiceStub(io.grpc.Channel channel) {
            super(channel);
        }

        private MessageServiceStub(io.grpc.Channel channel,
                                   io.grpc.CallOptions callOptions) {
            super(channel, callOptions);
        }

        @Override
        protected MessageServiceStub build(io.grpc.Channel channel,
                                           io.grpc.CallOptions callOptions) {
            return new MessageServiceStub(channel, callOptions);
        }

        /**
         *
         */
        public void controlTerminal(com.elinshaw.proto.Request request,
                                    io.grpc.stub.StreamObserver<com.elinshaw.proto.Response> responseObserver) {
            asyncUnaryCall(
                    getChannel().newCall(getControlTerminalMethod(), getCallOptions()), request, responseObserver);
        }
    }

    /**
     *
     */
    public static final class MessageServiceBlockingStub extends io.grpc.stub.AbstractStub<MessageServiceBlockingStub> {
        private MessageServiceBlockingStub(io.grpc.Channel channel) {
            super(channel);
        }

        private MessageServiceBlockingStub(io.grpc.Channel channel,
                                           io.grpc.CallOptions callOptions) {
            super(channel, callOptions);
        }

        @Override
        protected MessageServiceBlockingStub build(io.grpc.Channel channel,
                                                   io.grpc.CallOptions callOptions) {
            return new MessageServiceBlockingStub(channel, callOptions);
        }

        /**
         *
         */
        public com.elinshaw.proto.Response controlTerminal(com.elinshaw.proto.Request request) {
            return blockingUnaryCall(
                    getChannel(), getControlTerminalMethod(), getCallOptions(), request);
        }
    }

    /**
     *
     */
    public static final class MessageServiceFutureStub extends io.grpc.stub.AbstractStub<MessageServiceFutureStub> {
        private MessageServiceFutureStub(io.grpc.Channel channel) {
            super(channel);
        }

        private MessageServiceFutureStub(io.grpc.Channel channel,
                                         io.grpc.CallOptions callOptions) {
            super(channel, callOptions);
        }

        @Override
        protected MessageServiceFutureStub build(io.grpc.Channel channel,
                                                 io.grpc.CallOptions callOptions) {
            return new MessageServiceFutureStub(channel, callOptions);
        }

        /**
         *
         */
        public com.google.common.util.concurrent.ListenableFuture<com.elinshaw.proto.Response> controlTerminal(
                com.elinshaw.proto.Request request) {
            return futureUnaryCall(
                    getChannel().newCall(getControlTerminalMethod(), getCallOptions()), request);
        }
    }

    private static final int METHODID_CONTROL_TERMINAL = 0;

    private static final class MethodHandlers<Req, Resp> implements
            io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
            io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
            io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
            io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
        private final MessageServiceImplBase serviceImpl;
        private final int methodId;

        MethodHandlers(MessageServiceImplBase serviceImpl, int methodId) {
            this.serviceImpl = serviceImpl;
            this.methodId = methodId;
        }

        @Override
        @SuppressWarnings("unchecked")
        public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
            switch (methodId) {
                case METHODID_CONTROL_TERMINAL:
                    serviceImpl.controlTerminal((com.elinshaw.proto.Request) request,
                            (io.grpc.stub.StreamObserver<com.elinshaw.proto.Response>) responseObserver);
                    break;
                default:
                    throw new AssertionError();
            }
        }

        @Override
        @SuppressWarnings("unchecked")
        public io.grpc.stub.StreamObserver<Req> invoke(
                io.grpc.stub.StreamObserver<Resp> responseObserver) {
            switch (methodId) {
                default:
                    throw new AssertionError();
            }
        }
    }

    private static abstract class MessageServiceBaseDescriptorSupplier
            implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
        MessageServiceBaseDescriptorSupplier() {
        }

        @Override
        public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
            return com.elinshaw.proto.MessageProto.getDescriptor();
        }

        @Override
        public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
            return getFileDescriptor().findServiceByName("MessageService");
        }
    }

    private static final class MessageServiceFileDescriptorSupplier
            extends MessageServiceBaseDescriptorSupplier {
        MessageServiceFileDescriptorSupplier() {
        }
    }

    private static final class MessageServiceMethodDescriptorSupplier
            extends MessageServiceBaseDescriptorSupplier
            implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
        private final String methodName;

        MessageServiceMethodDescriptorSupplier(String methodName) {
            this.methodName = methodName;
        }

        @Override
        public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
            return getServiceDescriptor().findMethodByName(methodName);
        }
    }

    private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

    public static io.grpc.ServiceDescriptor getServiceDescriptor() {
        io.grpc.ServiceDescriptor result = serviceDescriptor;
        if (result == null) {
            synchronized (MessageServiceGrpc.class) {
                result = serviceDescriptor;
                if (result == null) {
                    serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
                            .setSchemaDescriptor(new MessageServiceFileDescriptorSupplier())
                            .addMethod(getControlTerminalMethod())
                            .build();
                }
            }
        }
        return result;
    }
}
